﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace CNVP.Config
{
    public class DBConfig
    {
        /// <summary>
        /// 数据表前缀
        /// </summary>
        public static string Prefix = BaseConfig.GetConfigValue("Prefix");
        /// <summary>
        /// 数据库类型
        /// </summary>
        public static string DBType = BaseConfig.GetConfigValue("DBType");
        /// <summary>
        /// 数据库链接地址
        /// </summary>
        public static string DBConn = BaseConfig.GetConfigValue("DBConn");
        /// <summary>
        /// 返回数据库链接
        /// </summary>
        public static string CommonConn
        {
            get
            {
                if (DBType == "Access")
                {
                    return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath(DBConn) + ";";
                }
                else
                {
                    return DBConn;
                }
            }
        }
        /// <summary>
        /// 刷新缓存
        /// </summary>
        public static void RefurbishCatch()
        {
            Prefix = BaseConfig.GetCatchParam("Prefix");
            DBType = BaseConfig.GetCatchParam("DBType");
            DBConn = BaseConfig.GetCatchParam("DBConn");
        }
    }
}